{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <input type="hidden" name="id" value="{$res['lunbo_id']}">
                        <input type="hidden" value="{$res['lunbo_type']}">
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="lunbo_name" value="{$res['lunbo_name']}" lay-verify="required" class="layui-input ">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">类别：</label>
                            <div class="layui-input-block">
                                <select name="lunbo_type" id="lunbo_type" lay-filter="lunbo_type" disabled>
                                    <option value="1" {if $res['lunbo_type']==1} selected {/if}>图片</option>
                                    <option value="2" {if $res['lunbo_type']==2} selected {/if}>视频</option>
                                </select>
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label" id="picture">图片：</label>
                            <input type="hidden" name="lunbo_image" id="lay-img" lay-verify="image">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览：
                                        <div class="layui-upload-list" id="lay-list">
                                            {if $res['lunbo_type']==1}
                                            <img class="layui-append-img" src="{$res.lunbo_image}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                            {else /}
                                            <video class="layui-append-img" src="{$res.lunbo_image}" controls></video>
                                            {/if}
                                        </div>
                                </blockquote>
                            </div>
                        </div>



                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">状态：</label>
                            <div class="layui-input-block">
                                <select name="lunbo_status">
                                    <option value="1" {if $res['lunbo_status']==1} selected {/if}>启用</option>
                                    <option value="2" {if $res['lunbo_status']==2} selected {/if}>禁用</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8 form-group">
                            <label class="layui-form-label">排序：</label>
                            <div class="layui-input-block">
                                <input type="text" value="{$res['lunbo_px']}" name="lunbo_px" lay-verify="required" class="layui-input" placeholder="值越小越靠前">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">编辑
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    var ttpye = $('#lunbo_type').val();
    if(ttpye == 1){
        wk.uploadImg({size:10,type:'jpg,png,jpeg',url:"{:url('Upload/uploadLocality')}",domain:""});
        $("#picture").text("图片：");
    }else{
        wk.uploadImg({size:10,type:'mp4',url:"{:url('Upload/uploadLocality')}",domain:""});
        $("#picture").text("视频：");
    }
    layui.use(['form','upload','layedit'], function() {
        var form = layui.form;
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('update')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Advert/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });
    });
</script>

</body>
</html>
